package com.sy.simpleegg.base

import android.view.View
import androidx.viewbinding.ViewBinding
import com.sy.simpleegg.ext.showToastMsg

abstract class BaseMvpFragment<in V: IView, P: IPresenter<V>, VB: ViewBinding>: BaseFragment<VB>(), IView {
    protected var mPresenter: P? = null
    protected abstract fun createPresenter(): P

    override fun initView(view: View) {
        mPresenter = createPresenter()
        mPresenter?.attachView(this as V)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        mPresenter?.detechView()
        this.mPresenter = null
    }

    override fun showToast(msg: String) {
        showToastMsg(msg)
    }
}